package com.codedef.library.controller;

import com.codedef.library.service.MailService;
import com.codedef.library.service.QueryService;
import com.codedef.library.util.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.Map;

@RestController
public class TestController {

    @Autowired
    MailService mailService;

    @GetMapping("/info2")
    public String info2() {
        mailService.sendHtmlMail("1138794994@qq.com", "图书馆预约系统Log",
                "已启动. 现在服务器时间：" + DateUtil.getDatetimeStr(new Date()));
        return "已发送至邮箱";
    }

    @GetMapping("/info1")
    public String info1() {
        return "现在服务器时间：" + DateUtil.getDatetimeStr(new Date());
    }

    @PostMapping("/testMap")
    public String testMap(@RequestBody Map<String, String> reqMap) {
        System.out.println("用户名：" + reqMap.get("Username"));
        System.out.println("密 码：" + reqMap.get("Password"));
        return reqMap.toString();
    }


}
